'''
@project:pytest_demo_t174
@auther:skj
@file:conftest.py
@date:2022/11/21 14:55
@desc:
'''
import pytest
import  requests
from common.request_define import RequestsDefine
@pytest.fixture()
def init_session_obj(request):
    global rd
    rd = RequestsDefine() #在所有的用例里面使用rd

    def close_session():  #关闭session对象
        rd.session.close()
    request.addfinalizer( close_session )  #addfinalizer() 类似yield#不能直接释放要等request请求调用完之后再释放
    return rd
@pytest.fixture()
def get_access_token():
    token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential"
    param={"appid":"wx688c435964125192","secret":"538e779f5baf13b8d1195bb5ef5a6526"}
    res=requests.get(url=token_url,params=param)
    token_data=res.json()
    return token_data['access_token']








